package com.atpy.reggie.controller;

import com.atpy.reggie.common.BaseContext;
import com.atpy.reggie.common.R;
import com.atpy.reggie.entity.Coupon;
import com.atpy.reggie.entity.CouponUser;
import com.atpy.reggie.service.CouponUserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/couponUser")
@Slf4j
public class couponUserController {
    @Autowired
    private CouponUserService couponUserService;
    @GetMapping("/list")
    public R<List> page(){
        LambdaQueryWrapper<CouponUser> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(CouponUser::getUserId, BaseContext.getCurrentId());
        wrapper.eq(CouponUser::getStatus,0);
        List<CouponUser> coupons = couponUserService.list(wrapper);
        return R.success(coupons);

    }
}
